function timeStamp2String(time, format) {
  var datetime = new Date();
  datetime.setTime(time * 1000);
  var year = datetime.getFullYear();
  var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
  var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime
    .getDate();
  var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime
    .getHours();
  var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
  var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
  var re = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
  var week = datetime.getDay();
  var weekday = new Array(7)
  weekday[0] = "日"
  weekday[1] = "一"
  weekday[2] = "二"
  weekday[3] = "三"
  weekday[4] = "四"
  weekday[5] = "五"
  weekday[6] = "六"
  if (format != null && format == 'l') {
    re = year + "-" + month + "-" + date + " " + hour + ":" + minute;
  }
  if (format != null && format == 'sd') {
    re = year + "-" + month + "-" + date;
  }
  if (format != null && format == 's') {
    re = month + "-" + date + " " + hour + ":" + minute;
  }
  if (format != null && format == 'd') {
    re = year + "-" + month + "-" + date;
  }
  if (format != null && format == 'Y') {
    re = year;
  }
  if (format != null && format == 'Hi') {
    re = hour + ":" + minute;
  }
  if (format != null && format == 'md') {
    re = year + "-" + month;
  }
  if (format != null && format == 'md2') {
    re = month + "月" + date + '日';
  }
  if (format != null && format == 'w') {
    re = "周" + weekday[week];
  }
  return re;
}

export default {
  lyhTime (value) {
    return "123"
  },
  showdate (timestamp, mode) {
    if (!timestamp) {
      return ''
    }
    var re = timestamp
    if (mode === 'md') {
      re = timeStamp2String(re, 'md2')
    } else if (mode === 'hm') {
      re = timeStamp2String(re, 'Hi')
    } else if (mode === 'ymdhm') {
      re = timeStamp2String(re, 'l')
    } else {
      re = timeStamp2String(re, 'sd')
    }
    return re
  }
}
